import moment from 'moment'

const timeFormat = {
    format: 'YYYY-MM-DD HH:mm:ss',
    format2: 'YYYY-MM-DD',
    format3: 'YYYY-MM-DD HH:mm',
    format4: 'YYYY-MM',
    format5: 'YYYY',
    format6: 'MM',
    format7: 'DD',
}

export default function timeFilter(time, type) {
    if (!time) {
        return ''
    }
    const formatType = timeFormat[type] || timeFormat.format
    const date = moment(time)
    const formattedDate = date.format(formatType)
    return formattedDate
}